Sondre U. Solstad
This package provides functions for visualizing AI / Machine Learning. Currently only one learning process is supported, namely LASSO regression with cross-validation.
Written by Sondre U. Solstad, Princeton University (ssolstad@princeton.edu). Send me an email if you find this package useful or want to suggest an improvement or feature.
Lasso coordinate descent and cross-validation:
Installation instructions:
library(devtools)
install_github("sondreus/seeAI")
library(seeAI)
library(glmnet)
set.seed(1010)
n=1000;p=100
nzc=trunc(p/10)
x=matrix(rnorm(n*p),n,p)
beta=rnorm(nzc)
fx= x[,seq(nzc)] %*% beta
eps=rnorm(n)*5
y=drop(fx+eps)
px=exp(fx)
px=px/(1+px)
ly=rbinom(n=length(px),prob=px,size=1)
set.seed(1011)
cvob1 <- cv.glmnet(x,y)
animate_glmnet(cvob1)
Line segments are coefficients, outward from the central circle being positive and inward negative. As the complexity parameter (“lambda”) is being reduced, the size and number of non-zero coefficients decreases. Once the process is complete, a cross-validation procedure selects the ideal model (with the cross-validation error and the standard deviation of this error plotted on the right). Typically, the simplest model with a cross-validation error less than one standard deviation more than the model with the lowest the cross-validation error is preferred.